﻿<Window x:Class="Microsoft.Research.ScientificWorkflow.SecurityControls.SecurityPolicyView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	Title="SystemPolicy"
	SizeToContent="WidthAndHeight"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        mc:Ignorable="d"
        ResizeMode="NoResize" ShowInTaskbar="False" WindowStyle="None" BorderBrush="#FF717171" WindowStartupLocation="CenterOwner"  Background="#FFFFFFFF" Topmost="False">

	<Window.Resources>
        <DataTemplate x:Key="lstboxTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="21.5"/>
                    <ColumnDefinition Width="*" MinWidth="26.098"/>
                </Grid.ColumnDefinitions>
                <Image Grid.ColumnSpan="1" Width="16" HorizontalAlignment="Center" Source="{Binding Path=SecurityPrincipal.ImagePath}" VerticalAlignment="Center" Height="16" />
                <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=DisplayName}" AutomationProperties.AutomationId="{Binding Path=DisplayName}"/>
            </Grid>
        </DataTemplate>
        
		<Style x:Key="PopupCloseButton" BasedOn="{x:Null}" TargetType="{x:Type Button}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Grid>
							<Rectangle Fill="#FFCCCCCC" Stroke="{x:Null}" RadiusX="4.5" RadiusY="4.5" x:Name="rectangle"/>
							<Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" Margin="8,3.5,7,3.5" RenderTransformOrigin="0.5,0.5">
								<Rectangle.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="-34.039"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Rectangle.RenderTransform>
							</Rectangle>
							<Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" RenderTransformOrigin="0.5,0.5" Margin="8,3.5,7,3.5">
								<Rectangle.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="-1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="34.039"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Rectangle.RenderTransform>
							</Rectangle>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsFocused" Value="True"/>
							<Trigger Property="IsDefaulted" Value="True"/>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Fill" TargetName="rectangle" Value="#FFADADAD"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="True"/>
							<Trigger Property="IsEnabled" Value="False"/>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</Window.Resources>

	<Grid x:Name="LayoutRoot">
		<Border BorderBrush="#FFBDBDBD" BorderThickness="1,1,2,2" CornerRadius="4,4,4,4">
			<Border.Background>
				<LinearGradientBrush EndPoint="0.5,0.665" StartPoint="0.5,0">
                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                    <GradientStop Color="#FFE9E9E9" Offset="1"/>
				</LinearGradientBrush>
			</Border.Background>
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="28"/>
					<RowDefinition Height="*"/>
					<RowDefinition Height="38"/>
				</Grid.RowDefinitions>
				<Border Name="brdrHeader" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Grid.Row="0" CornerRadius="4,4,0,0">
					<Border.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFF7F7F7" Offset="0"/>
							<GradientStop Color="#FFE9E9E9" Offset="1"/>
						</LinearGradientBrush>
					</Border.Background>
					<Grid>
						<TextBlock HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" Foreground="#FF5F5F5F" Text="System Policy" TextWrapping="Wrap"/>
						<Button HorizontalAlignment="Right" Margin="0,5.5,5,5.5" Style="{DynamicResource PopupCloseButton}" Width="17" Content="Button" x:Name="closeButton" Command="{Binding Path=CloseScheduleWindowCommand}"/>
					</Grid>
				</Border>
				<Button IsCancel="True" HorizontalAlignment="Right" Width="70" Content="Cancel" Margin="0,0,10,0" VerticalAlignment="Center" Grid.Row="2" Command="{Binding Path=CloseScheduleWindowCommand}"/>
				<Button IsDefault="True" HorizontalAlignment="Right" Width="70" Content="OK" Margin="0,0,85,0" VerticalAlignment="Center" Grid.Row="2" d:LayoutOverrides="Height" Command="{Binding Path=SavePolicyCommand}"/>
				<Border Grid.Row="1" Background="#FFF1F1F1">
					<ScrollViewer VerticalScrollBarVisibility="Auto" Padding="0,0,20,10">
						<StackPanel Margin="10,0,0,0">
							<CheckBox IsChecked="{Binding Path=AnonymousEnabled}" Content="Enable Anonymous" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
							<!--<CheckBox IsChecked="{Binding Path=AutoCreateUserIfGroupMatch}" Content="Automatically create user if group matches" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>-->                            
                            <TextBlock HorizontalAlignment="Left" Margin="10,10,0,2" VerticalAlignment="Top" Text="Administrators" TextWrapping="Wrap"/>
							<StackPanel Orientation="Horizontal" Visibility="Visible" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top">
								<ListBox x:Name="adminList" SelectionChanged="adminList_SelectionChanged" ItemsSource="{Binding Path=Administrators}" ItemTemplate="{StaticResource lstboxTemplate}"  Width="250" IsSynchronizedWithCurrentItem="True" Height="65" SelectedIndex="0" SelectionMode="Single" AutomationProperties.AutomationId="AUIAdminLst"/>
								<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="5,5,0,0" VerticalAlignment="Bottom">
									<Button Width="60" Content="Add" HorizontalAlignment="Left" Command="{Binding Path=AddAdministratorCommand}"/>
									<Button Width="60" Content="Remove" Margin="0,5,0,0" VerticalAlignment="Top" Command="{Binding Path=RemoveAdministratorCommand}"/>
								</StackPanel>
							</StackPanel>
							<TextBlock Text="Users" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="10,10,0,2" VerticalAlignment="Top"/>
							<StackPanel Orientation="Horizontal" Visibility="Visible" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top">
								<ListBox Width="250" SelectionChanged="userList_SelectionChanged" IsSynchronizedWithCurrentItem="True" Height="65" x:Name="userList" ItemsSource="{Binding Path=Users}" ItemTemplate="{StaticResource lstboxTemplate}" SelectionMode="Single" VirtualizingStackPanel.VirtualizationMode="Standard" SelectedIndex="0"/>
								<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="5,5,0,0" VerticalAlignment="Bottom">
									<Button Width="60" Content="Add" HorizontalAlignment="Left" Command="{Binding Path=AddUserCommand}"/>
									<Button Width="60" Content="Remove" Margin="0,5,0,0" VerticalAlignment="Top" Command="{Binding Path=RemoveUserCommand}"/>
								</StackPanel>
							</StackPanel>
							<TextBlock Text="Guests" TextWrapping="Wrap" Margin="10,10,0,2" HorizontalAlignment="Left" VerticalAlignment="Top"/>
							<StackPanel Orientation="Horizontal" Visibility="Visible" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top">
								<ListBox x:Name="guestList" SelectionChanged="guestList_SelectionChanged" ItemsSource="{Binding Path=Guests}" ItemTemplate="{StaticResource lstboxTemplate}" Width="250" IsSynchronizedWithCurrentItem="True" Height="65"/>
								<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="5,5,0,0" VerticalAlignment="Bottom">
									<Button Width="60" Content="Add" HorizontalAlignment="Left" Command="{Binding Path=AddGuestCommand}"/>
									<Button Width="60" Content="Remove" Margin="0,5,0,0" VerticalAlignment="Top" Command="{Binding Path=RemoveGuestCommand}"/>
								</StackPanel>
							</StackPanel>
						</StackPanel>
					</ScrollViewer>
				</Border>
			</Grid>
		</Border>
	</Grid>
</Window>